const p = console.log;
function isInViewport2(e) {
    const rect = e.getBoundingClientRect();
    return ( rect.top < window.innerHeight && rect.bottom > 0 && rect.left < window.innerWidth && rect.right > 0 );
}
function isInViewport(e) {
    const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
    const offsetTop = e.offsetTop;
    const windowHeight = window.innerHeight;
    const elementHeight = e.offsetHeight;

    return (
            offsetTop - scrollTop < windowHeight &&
            offsetTop - scrollTop + elementHeight > 0
    );
}
function getSuffix(s) {
    let sl = s.split('.');
    if (sl.length <= 1) {
        return '';
    }
    return '.' + sl[sl.length -1].toLowerCase();
}
function setNewSuffix(s, suffix) {
    if (suffix == '') {
    } else if (suffix[0] != '.') {
        suffix = '.' + suffix;
    }
    let old = getSuffix(s);
    if (!old) {
        return s + suffix;
    }
    return s.slice(0, s.length - old.length) + suffix;
}
function getFileName(s) {
    let sl = s.split('/');
    return decodeURI(sl[sl.length -1]);
}
function setClipboardText(text) {
    try {
        const t = document.createElement('textarea');
        t.nodeValue = text;
        t.value = text;
        document.body.appendChild(t);
        t.select();
        document.execCommand('copy');
        document.body.removeChild(t);
        return { 'res': true, 'msg': '' };
    } catch (e) {
        return { 'res': false, 'msg': e };
    }
}

function delay(time) {
  return new Promise((resolve) => {
    setTimeout(resolve, time);
  });
}
function pushWindowOnload(f) {
    const old = window.onload;
    window.onload = () => {
        if (old) old();
        if (f) f();
    }
}
let fadeCssDom = document.createElement('style');
fadeCssDom.setAttribute('type', 'text/css');
fadeCssDom.innerHTML = `
@keyframes fadein {
    0% { opacity: 0; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
@keyframes fadeout {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 0; }
}
@keyframes translucent {
    0% { opacity: 1; }
    50% { opacity: 0.75; }
    100% { opacity: 0.5; }
}
@keyframes untranslucent {
    0% { opacity: 0.5; }
    50% { opacity: 0.75; }
    100% { opacity: 1; }
}
`;
document.head.appendChild(fadeCssDom);
function setElementAnimation(e, a, t) {
    e.style.animation = `${a} ${t}s`;
}
function fadein(e, t) {
    t = t === undefined ? 0.5 : t;
    setElementAnimation(e, 'fadein', t);
    e.style.display = 'unset';
}
function fadeout(e, t) {
    t = t === undefined ? 0.5 : t;
    setElementAnimation(e, 'fadeout', t);
    setTimeout(() => {
        e.style.display = 'none';
    }, t * 1000);
}
function translucent(e, t) {
    t = t === undefined ? 0.5 : t;
    setElementAnimation(e, 'translucent', t);
    setTimeout(() => {
        e.style.opacity = '0.5';
    }, t * 1000);
}
function untranslucent(e, t) {
    t = t === undefined ? 0.5 : t;
    setElementAnimation(e, 'untranslucent', t);
    setTimeout(() => {
        e.style.opacity = '1';
    }, t * 1000);
}
function isElementHidden(e) {
    return (e.style.opacity == '0' ||
        e.style.visibility == 'hidden' || 
        e.style.visibility == 'collapse' ||
        e.style.display == 'none');
}
function isIterable(obj) {
  return typeof obj[Symbol.iterator] === 'function';
}
function showFullScreen (e) {
    let requestMethod = e.requestFullScreen || e.webkitRequestFullScreen || e.mozRequestFullScreen || e.msRequestFullScreen;
    requestMethod.call(e);
}
function isFullScreen() {
    return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullscreenElement || document.msFullscreenElement;
}
function exitFullScreen () {
    let e;
    if (document.fullscreenElement) {
        document.exitFullscreen();
    } else if (e = document.mozFullscreenElement) {
        e.mozCancelFullScreen();
    } else if (e = document.webkitFullscreenElement) {
        e.webkitCancelFullScreen();
    } else if (e = document.msFullscreenElement) {
        e.msCancelFullScreen();
    } else {

    }
}
pushWindowOnload(() => {
    const domPathList = document.getElementById('path-list');
    let homeUrl = domPathList.getElementsByTagName('a')[0].href;
    const curUrl = location.href.split('#')[0].split('?')[0].slice(homeUrl.length);
    let pathList = curUrl.split('/');
    let fullHtml = '';
    for (let i = 0; i < pathList.length; i++) {
        if (!pathList[i]) break;
        if (i == 0) homeUrl += pathList[i];
        else homeUrl += `/${pathList[i]}`;
        let endChar = '/';
        if (i == pathList.length - 1) {
            if (curUrl[curUrl.length - 1] != '/') {
                endChar = '';
            }
        }
        fullHtml += `<span>&gt;</span><a href="${homeUrl}${endChar}">${decodeURIComponent(pathList[i])}</a>`
    }
    domPathList.innerHTML += fullHtml;
});